Skip to content

fix(json): flatten view command JSON output for --fields filtering#495

Merged
BYK merged 1 commit intomainfrom
perf/resolve-project-data
Mar 20, 2026
Merged

fix(json): flatten view command JSON output for --fields filtering#495
BYK merged 1 commit intomainfrom
perf/resolve-project-data

Conversation

@BYK
Copy link
Member

@BYK BYK commented Mar 20, 2026

Summary

issue view, event view, and trace view commands yielded wrapper objects (e.g., { issue, event, trace }) as their CommandOutput data. When --fields was used, filterFields looked for field names at the top level of this wrapper, so --fields shortId,title returned {} because those fields lived inside the nested issue object.

Fix

Add jsonTransform to all three view commands that spreads the primary entity as the top-level object:

  • issue view: { ...issue, event, trace }
  • event view: { ...event, trace }
  • trace view: { ...summary, spans }

This makes --fields shortId,title work directly on issue properties, while enrichment data remains accessible via --fields event.id or --fields trace.traceId.

Test plan

  • bun test test/commands/trace/view.func.test.ts — updated assertions for flattened JSON structure
  • Manual: sentry issue view <id> --json --fields shortId,title,count should return filtered fields instead of {}

@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • (telemetry) Track TTY vs non-TTY invocations via metric by betegon in #482
  • Dynamic cache-backed shell completions with fuzzy matching by BYK in #465

Bug Fixes 🐛

  • (help) Hide ASCII banner when stdout is not a TTY by betegon in #501
  • (json) Flatten view command JSON output for --fields filtering by BYK in #495
  • (project) Fallback to org listing when bare slug matches an organization by betegon in #475
  • Use resolved org in numeric issue ID 404 hint (CLI-BT) by BYK in #502
  • Include API endpoint in error messages for better diagnostics (CLI-BS) by BYK in #500
  • Enrich 403 on org listing with token scope guidance (CLI-89) by BYK in #498
  • Add 400 suggestions to org-all issue list path (CLI-BY) by BYK in #497
  • Lowercase project slug in issue arg parsing (CLI-C8) by BYK in #496
  • Enrich short ID 404 with org context and suggestions (CLI-A1) by BYK in #494
  • Suggest similar projects when project not found in org (CLI-C0) by BYK in #493
  • Event 404 hint should suggest different project, not repeat failing command by BYK in #492
  • Enrich event 404 errors with retention and format suggestions (CLI-6F) by BYK in #491
  • Add actionable suggestions for 400 Bad Request on issue list (CLI-BM, CLI-7B) by BYK in #489
  • Detect issue short IDs passed to issue list (CLI-C3) by BYK in #488
  • Add Glob.match() polyfill + improve auto-detect diagnostics (CLI-7T) by BYK in #487
  • Add org-slug pre-check to dispatchOrgScopedList (CLI-9A) by BYK in #485

Internal Changes 🔧

  • (issue) Skip getProject round-trip in project-search resolution by betegon in #473
  • (resolve) Carry project data through resolution to eliminate redundant getProject calls by BYK in #486
  • (telemetry) Convert is_tty metric to span tag by betegon in #499
  • HTTP latency optimizations — diagnostics, cache warming, concurrency limits by BYK in #490
  • Switch from @sentry/bun to @sentry/node-core/light (~170ms startup savings) by BYK in #474
  • Regenerate skill files by github-actions[bot] in b7b240ec

🤖 This preview updates automatically when you update the PR.

@BYK BYK force-pushed the perf/resolve-project-data branch from 15899fe to 1037646 Compare March 20, 2026 10:42
@BYK BYK changed the title perf(resolve): carry project data through resolution to skip redundant API calls fix(json): flatten view command JSON output for --fields filtering Mar 20, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 20, 2026

Codecov Results 📊

126 passed | Total: 126 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests
Failed Tests
Skipped Tests

✨ No test changes detected

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 1071 uncovered lines.
❌ Project coverage is 95.67%. Comparing base (base) to head (head).

Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
- Coverage    95.68%    95.67%    -0.01%
==========================================
  Files          180       180         —
  Lines        24704     24724       +20
  Branches         0         0         —
==========================================
+ Hits         23637     23653       +16
- Misses        1067      1071        +4
- Partials         0         0         —

Generated by Codecov Action

@BYK BYK marked this pull request as ready for review March 20, 2026 10:44
issue view, event view, and trace view commands yielded wrapper objects
(e.g., { issue, event, trace }) as their CommandOutput data. When --fields
was used, filterFields looked for field names at the top level of this
wrapper, so --fields shortId,title returned {} because those fields
lived inside the nested 'issue' object.

Add jsonTransform to all three view commands that spreads the primary
entity as the top-level object:
- issue view: { ...issue, event, trace }
- event view: { ...event, trace }
- trace view: { ...summary, spans }

This makes --fields shortId,title work directly on issue properties,
while enrichment data remains accessible via --fields event.id or
--fields trace.traceId.

The jsonTransform also handles spanTreeLines exclusion (previously done
via jsonExclude) since the transform controls the full JSON shape.
@BYK BYK force-pushed the perf/resolve-project-data branch from 1037646 to d9400d7 Compare March 20, 2026 10:46
@BYK BYK merged commit 830f455 into main Mar 20, 2026
22 checks passed
@BYK BYK deleted the perf/resolve-project-data branch March 20, 2026 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant